function getDateAferDays(dataStr, days) {
    var oDate = new Date(dataStr);
    oDate.setDate(oDate.getDate() + days)
    oYear = oDate.getFullYear();
    oMonth = oDate.getMonth() + 1;
    oDay = oDate.getDate();
    oHour = 0;
    oMin = 0;
    oSen = 0;
    oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay) + ' ' + getzf(oHour) + ':' + getzf(oMin) + ':' + getzf(oSen);
    return oTime;
};

function getMyDate(str) {
    var oDate = new Date(str),
        oYear = oDate.getFullYear(),
        oMonth = oDate.getMonth() + 1,
        oDay = oDate.getDate(),
        oHour = oDate.getHours(),
        oMin = oDate.getMinutes(),
        oSen = oDate.getSeconds(),
        oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay);//最后拼接时间
    return oTime;
};

function getMyDateTime(str) {
    if (paramIsEmpty(str)) {
        return "";
    }
    var oDate = new Date(str),
        oYear = oDate.getFullYear(),
        oMonth = oDate.getMonth() + 1,
        oDay = oDate.getDate(),
        oHour = oDate.getHours(),
        oMin = oDate.getMinutes(),
        oSen = oDate.getSeconds(),
        oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay) + ' ' + getzf(oHour) + ':' + getzf(oMin) + ':' + getzf(oSen);//最后拼接时间
    return oTime;
};

//补0操作
function getzf(num) {
    if (parseInt(num) < 10) {
        num = '0' + num;
    }
    return num;
}

//获取当前时间，格式YYYY-MM-DD
function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}


//获取昨天时间，格式YYYY-MM-DD
function getYesterdayFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() - 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}

function getYesterdayFormatDate() {
    var date = new Date();
    date.setTime(date.getTime() - 24 * 60 * 60 * 1000);
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}

function getTomorrowdayFormatDate() {
    var date = new Date();
    date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}

//取两位小数,不足补0
function returnFloat(value) {
    var value = Math.round(parseFloat(value) * 100) / 100;
    var xsd = value.toString().split(".");
    if (xsd.length == 1) {
        value = value.toString() + ".00";
        return value;
    }
    if (xsd.length > 1) {
        if (xsd[1].length < 2) {
            value = value.toString() + "0";
        }
        return value;
    }
}

function Fen2Yuan(num) {
    if (typeof num !== "number" || isNaN(num)) {
        return 0;
    }
    return (num / 100).toFixed(2) + '元';
}

function getCookie(name) {
    if (document.cookie.length > 0) {
        start = document.cookie.indexOf(name + "=");
        if (start != -1) {
            start = start + name.length + 1;
            end = document.cookie.indexOf(";", start);
            if (end == -1)
                end = document.cookie.length;
            return unescape(document.cookie.substring(start, end));
        }
    }
    return "";
}


function formatDateTime(date, fmt) {
    var o = {
        "M+": date.getMonth() + 1, //月份
        "d+": date.getDate(), //日
        "h+": date.getHours(), //小时
        "m+": date.getMinutes(), //分
        "s+": date.getSeconds(), //秒
        "q+": Math.floor((date.getMonth() + 3) / 3), //季度
        "S": date.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

function getMyDateFomatTime(str, fmt) {
    var oDate = new Date(str);
    return formatDateTime(oDate, fmt);
}

function isNotEmpty(str) {
    if (typeof str == "undefined" || str == null || str == "") {
        return false;
    } else {
        return true;
    }
}

/**
 * 参数是否不为空
 * @param param
 * @returns {Boolean}
 */
function paramIsNotEmpty(param) {
    if (param != null && param != "" && param != undefined && param != 'undefined' && param != 'null') {
        return true;
    } else {
        return false;
    }
}

/**
 * 参数是否为空
 * @param param
 * @returns {Boolean}
 */
function paramIsEmpty(param) {
    if (param == null || param == "" || param == undefined) {
        return true;
    } else {
        return false;
    }
}

/**
 * 保存数据到会话
 * @param key
 * @param data
 */
function putStorage(key, data) {
    if (!window.sessionStorage) {
        alert("浏览器不支持sessionStorage");
    } else {
        var storage = window.sessionStorage;
        var d = JSON.stringify(data);
        storage.setItem(key, d);
    }
}

/**
 * 取会话里的数据
 * @param key
 * @returns
 */
function getStorage(key) {
    var storage = window.sessionStorage;
    var json = storage.getItem(key);
    var jsonObj = JSON.parse(json);
    return jsonObj;
}

/**
 * 分转元保留两位小数
 * @param number
 * @returns
 */
function fenToYuan(number) {
    if ("0" == number) {
        return "0.00";
    }
    if (paramIsEmpty(number)) {
        return "";
    }

    number = parseFloat((number / 100).toFixed(2));

    var reg = /^[-\+]?\d+$/;
    if (reg.test(number)) {

        return number + ".00";
    } else {
        var numberStr = (number + "").split(".");
        if (numberStr != null) {
            if (numberStr.length == 2 && numberStr[1].length == 1) {
                return number + "0";
            }
        }
    }

    return number;
}

/**
 * 获取空字符串
 * @param param
 * @returns
 */
function getNullString(param) {
    if (param == null || param == undefined || "NaN" == param || "undefined" == param) {
        return "";
    } else {
        return param;
    }
}

/**
 * 精确除法
 */
function divide(num1, num2) {
    var others = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        others[_i - 2] = arguments[_i];
    }
    if (others.length > 0) {
        return divide.apply(void 0, [divide(num1, num2), others[0]].concat(others.slice(1)));
    }
    var num1Changed = float2Fixed(num1);
    var num2Changed = float2Fixed(num2);
    checkBoundary(num1Changed);
    checkBoundary(num2Changed);
    return times((num1Changed / num2Changed), Math.pow(10, digitLength(num2) - digitLength(num1)));
}

/**
 * 精确乘法
 */
function times(num1, num2) {
    var others = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        others[_i - 2] = arguments[_i];
    }
    if (others.length > 0) {
        return times.apply(void 0, [times(num1, num2), others[0]].concat(others.slice(1)));
    }
    var num1Changed = float2Fixed(num1);
    var num2Changed = float2Fixed(num2);
    var baseNum = digitLength(num1) + digitLength(num2);
    var leftValue = num1Changed * num2Changed;
    checkBoundary(leftValue);
    return leftValue / Math.pow(10, baseNum);
}

/**
 * 检测数字是否越界，如果越界给出提示
 * @param {*number} num 输入数
 */
function checkBoundary(num) {
    if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
        console.warn(num + " is beyond boundary when transfer to integer, the results may not be accurate");
    }
}

/**
 * 把小数转成整数，支持科学计数法。如果是小数则放大成整数
 * @param {*number} num 输入数
 */
function float2Fixed(num) {
    if (num.toString().indexOf('e') === -1) {
        return Number(num.toString().replace('.', ''));
    }
    var dLen = digitLength(num);
    return dLen > 0 ? num * Math.pow(10, dLen) : num;
}

/**
 * Return digits length of a number
 * @param {*number} num Input number
 */
function digitLength(num) {
    // Get digit length of e
    var eSplit = num.toString().split(/[eE]/);
    var len = (eSplit[0].split('.')[1] || '').length - (+(eSplit[1] || 0));
    return len > 0 ? len : 0;
}